package com.cyx.service;

import com.cyx.mapper.BookMapper;
import com.cyx.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("bookService")
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;
    @Override
    @Transactional
    public int addBook(Book book) {
        return bookMapper.addBook(book);
    }

    @Override
    public Book getBook(int bookId) {
        return bookMapper.getBookById(bookId);
    }

    @Override
    public int updateBook(Book book) {
        return bookMapper.updateBook(book);
    }

    @Override
    public int reduceBookStock(int bookId) {
        return bookMapper.reduceBookStock(bookId);
    }

    @Override
    public int increaseBookStock(int bookId) {
        return bookMapper.increaseBookStock(bookId);
    }

    public List<Book> getBooks(String bookName, String bookDetail){
        return bookMapper.getBookList(bookName,bookDetail);
    }
}
